<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>出库单工具</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="出库单工具">
<link rel="stylesheet" type="text/css" href="<%=path%>/easyui/themes/gray/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/easyui/themes/icon.css">
<script type="text/javascript" src="<%=path%>/easyui/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=path%>/easyui/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=path%>/easyui/js/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=path%>/easyui/js/con_isok.js"></script>

</head>
<body class="easyui-layout">

<div data-options="region:'north',border:false" style="padding:2px;">
	<table align="">
		<tr>
			<td>出库单号:</td>
			<td><input id="ckd_no_id" class="easyui-numberbox" value=""></td>
			<td>油站代码: </td>
			<td><input id="node_no_id" class="easyui-numberbox" value=""></td>
		</tr>
		<tr>
			<td>开始时间:</td>
				<td><input id="begin_time_id" class="easyui-datebox" data-options="editable:false">
			</td>
			<td>结束时间:</td>
				<td><input id="end_time_id" class="easyui-datebox" data-options="editable:false">
			</td>
		</tr>
		<tr>
			<td align="center"><a id="select_btn" href="javascript:void(0);" class="easyui-linkbutton" onclick="select_data1();">查询</a></td>
<%--			<td align="center"><a id="select_btn" href="javascript:void(0);" class="easyui-linkbutton" onclick="upload();">上传</a></td>--%>
			<td align="center"><a id="select_btn" href="javascript:void(0);" class="easyui-linkbutton" onclick="reset1();">重置传输位</a></td>
		</tr>
	</table>
</div>

<div data-options="region:'center', border:false" style="padding:2px;">
	<table id="dg" class="easyui-datagrid" data-options="
			url:'<%=path %>/ckd/index.do',
			fit:true,
			singleSelect:false,
			fitColumns: true,
			border:false,
			pagination: true,
			onClickRow:onClickRow
	">
		<thead>
			<tr>
			
				<th data-options="field:'psdId',width:100">配送单号</th>
				<th data-options="field:'fromDepotName',width:100">油库名称</th>
				<th data-options="field:'deliveryTime',width:100">出库时间</th>
				<th data-options="field:'oilNo',width:100">油品编码</th>
				<th data-options="field:'toNodeNo',width:100">油站代码</th>
				<th data-options="field:'deliveryTemp',width:100">出库温度</th>
				<th data-options="field:'planL',width:100">原发体积</th>
				<th data-options="field:'planTon',width:100">原发重量</th>
				<th data-options="field:'carNo',width:100">车牌号</th>
				<th data-options="field:'tranStatus',width:100">传输状态</th>
			</tr>
		</thead>
	</table>
</div>
	<script type="text/javascript">
		
		function onClickRow(rowIndex,rowData){
			if(rowData.tranStatus == "0"){
				$.messager.alert("提示","该条数据不能重置!", "error");
				$('#dg').datagrid('unselectRow',rowIndex);
			}
		}
	
		function select_data1(){
			isOkCon("", "<%=path %>","select_data()");
		}
		
		function select_data(){
			var ckdNo = $("#ckd_no_id").val();
			var nodeNo = $("#node_no_id").val();
			var beginTime = $("#begin_time_id").datebox('getValue');
			var endTime = $("#end_time_id").datebox('getValue');
			
			$("#dg").datagrid('load', {
				ckdNo:ckdNo,
				nodeNo:nodeNo,
				beginTime:beginTime,
				endTime:endTime,
				selectType:"1"
			});
		}
		
		
		function reset1(){
			var rows = $("#dg").datagrid("getSelections");
			if(rows.length == 0){
				$.messager.alert("提示","请选择一条数据!", "error");
				return;
			}
			isOkCon("", "<%=path %>","reset()");
		}
		
		
		function reset(){
			var rows = $("#dg").datagrid("getSelections");
			if(rows.length == 0){
				$.messager.alert("提示","请选择一条数据!", "error");
				return;
			}
			
			var ckdNoArray = [];
			for(var i = 0; i < rows.length; i++){
				ckdNoArray.push(rows[i].deliveryNo);
			}
			
			$.messager.progress({title: "提示", msg: "正在重置传输位..."});
			$.ajax({
				url: "<%=path %>/ckd/reset.do",
				type: "post",
				dataType: "json",
				contentType:"application/json",
				data: JSON.stringify(ckdNoArray),
				success:function(data){
					if(data){
						$.messager.alert("提示","修改成功!", "info");
					}else{
						$.messager.alert("提示","修改失败!", "error");
					}
				},
				complete:function(){
					$('#dg').datagrid('reload');
			 		$.messager.progress('close');
			 	}
			});
		}
		
	</script>
	
	
	
</body>
</html>
